package com.wicket.okrbff.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrbff.biz.service.NetDiskTargetContentService;
import com.wicket.okrbff.biz.service.dto.req.*;
import com.wicket.okrbff.biz.service.dto.res.*;
import com.wicket.okrbff.common.ro.OkrResult;
import com.wicket.okrbff.common.ro.OkrResult;
import com.wicket.okrbff.common.util.CommonFunctionHelper;
import com.wicket.okrbff.common.util.RedisUtil;
import javax.annotation.Resource;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import com.wicket.okrapp.integration.FwAppNetDiskTargetContentClient;
import com.wicket.okrapp.integration.dto.QueryNetDiskEvaTreeListComRespDto;
import com.wicket.okrapp.integration.dto.QueryNetDiskEvaTreeListComReqDto;
import com.wicket.okrbff.biz.service.dto.common.BffEvaObjTargetCycleDto;
import com.wicket.okrbff.common.dto.TreeNode;
import java.util.ArrayList;
import java.util.stream.Collectors;
import java.util.List;
import com.wicket.okrbff.common.exception.Assert;
import com.wicket.okrapp.integration.dto.QueryNetDiskTreeSubordinateListComRespDto;
import com.wicket.okrapp.integration.dto.QueryNetDiskTreeSubordinateListComReqDto;
import com.wicket.okrbff.biz.service.dto.common.BffSubTargetContentDto;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@Service
public class NetDiskTargetContentServiceImpl
  implements NetDiskTargetContentService {

  @Resource
  private RedisUtil redisUtil;
@Resource
  FwAppNetDiskTargetContentClient fwAppNetDiskTargetContentClient;
/**
   * B3查询网盘评价树列表(管理)[8839]
   * gen by moon at 3/28/2024, 2:13:07 PM
   */
    @Trace(operationName = "B3查询网盘评价树列表(管理)")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffQueryNetDiskEvaTreeListRespDto queryNetDiskEvaTreeList(BffQueryNetDiskEvaTreeListReqDto reqDto){
      
       
       QueryNetDiskEvaTreeListComRespDto queryNetDiskEvaTreeListComRespDto_1 =null;
//步骤0: D3查询网盘评价树列表(公共) - queryNetDiskEvaTreeListCom
     QueryNetDiskEvaTreeListComRespDto queryNetDiskEvaTreeListComRespDto = null;
    QueryNetDiskEvaTreeListComReqDto queryNetDiskEvaTreeListComReqDto=new QueryNetDiskEvaTreeListComReqDto();
queryNetDiskEvaTreeListComReqDto.setIsParentCycle("TRUE");//sourceId:1661120_1
queryNetDiskEvaTreeListComReqDto.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:1661121_1
if(reqDto!=null){
      queryNetDiskEvaTreeListComReqDto.setEvaObjTypeCode(reqDto.getEvaObjTypeCode());//SimpleFieldAssign//sourceId:1661119_1
      queryNetDiskEvaTreeListComReqDto.setEvaluationTemplateId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:1661122_1
    }
  
    /*D3查询网盘评价树列表(公共)[8838]   */
    Assert.isNull(queryNetDiskEvaTreeListComReqDto.getEvaObjTypeCode(),"B3查询网盘评价树列表(管理)-D3查询网盘评价树列表(公共)-被评对象类型编码不能为空",false);
Assert.isNull(queryNetDiskEvaTreeListComReqDto.getEvaluationTemplateId(),"B3查询网盘评价树列表(管理)-D3查询网盘评价树列表(公共)-冗余评价模板ID不能为空",false);
Assert.isNull(queryNetDiskEvaTreeListComReqDto.getIsParentCycle(),"B3查询网盘评价树列表(管理)-D3查询网盘评价树列表(公共)-是否父周期不能为空",false);
Assert.isNull(queryNetDiskEvaTreeListComReqDto.getSubjectLifeCycle(),"B3查询网盘评价树列表(管理)-D3查询网盘评价树列表(公共)-主体生命周期不能为空",false);
      queryNetDiskEvaTreeListComRespDto = fwAppNetDiskTargetContentClient.queryNetDiskEvaTreeListCom(queryNetDiskEvaTreeListComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;
      
      
      queryNetDiskEvaTreeListComRespDto_1 = queryNetDiskEvaTreeListComRespDto;
    
BffQueryNetDiskEvaTreeListRespDto retData = new BffQueryNetDiskEvaTreeListRespDto();
  if(queryNetDiskEvaTreeListComRespDto_1!=null){
      retData.setEvaObjTargetCycleList(queryNetDiskEvaTreeListComRespDto_1.getEvaObjTargetCycleList().stream().map(item -> BeanUtil.toBean(item, BffEvaObjTargetCycleDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1661136_1
    }
  

      List<Object> allNodes =new ArrayList<>();
      allNodes.addAll(retData.getEvaObjTargetCycleList());
     List<TreeNode> nodeList = CommonFunctionHelper.buildTree(allNodes);
     retData.setTreeNode(nodeList);
     retData.setEvaObjTargetCycleList(null);
    
return retData;
  }
/**
   * B3查询网盘树节点下级列表(管理)[8840]
   * gen by moon at 5/11/2024, 11:58:09 PM
   */
    @Trace(operationName = "B3查询网盘树节点下级列表(管理)")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffQueryNetDiskTreeSubordinateListRespDto queryNetDiskTreeSubordinateList(BffQueryNetDiskTreeSubordinateListReqDto reqDto){


       QueryNetDiskTreeSubordinateListComRespDto queryNetDiskTreeSubordinateListComRespDto_1 =null;
//步骤0: D3查询网盘树节点下级内容列表(公共) - queryNetDiskTreeSubordinateListCom
     QueryNetDiskTreeSubordinateListComRespDto queryNetDiskTreeSubordinateListComRespDto = null;
    QueryNetDiskTreeSubordinateListComReqDto queryNetDiskTreeSubordinateListComReqDto=new QueryNetDiskTreeSubordinateListComReqDto();
  if(reqDto!=null){
      queryNetDiskTreeSubordinateListComReqDto.setEvaObjTypeCode(reqDto.getEvaObjTypeCode());//SimpleFieldAssign//sourceId:1661521_1
queryNetDiskTreeSubordinateListComReqDto.setParentEvaObjTargetCycleId(reqDto.getParentEvaObjTargetCycleId());//SimpleFieldAssign//sourceId:1661461_1
queryNetDiskTreeSubordinateListComReqDto.setTargetCycleContentTypeCode(reqDto.getTargetCycleContentTypeCode());//SimpleFieldAssign//sourceId:1661460_1
queryNetDiskTreeSubordinateListComReqDto.setIsLastTargetContent(reqDto.getIsLastTargetContent());//SimpleFieldAssign//sourceId:1661463_1
queryNetDiskTreeSubordinateListComReqDto.setEvaluationTemplateId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:1661462_1
    }

    /*D3查询网盘树节点下级内容列表(公共)[8837]   */
    Assert.isNull(queryNetDiskTreeSubordinateListComReqDto.getEvaObjTypeCode(),"B3查询网盘树节点下级列表(管理)-D3查询网盘树节点下级内容列表(公共)-被评对象类型编码不能为空",false);
Assert.isNull(queryNetDiskTreeSubordinateListComReqDto.getParentEvaObjTargetCycleId(),"B3查询网盘树节点下级列表(管理)-D3查询网盘树节点下级内容列表(公共)-上级被评对象目标周期标识不能为空",false);
Assert.isNull(queryNetDiskTreeSubordinateListComReqDto.getTargetCycleContentTypeCode(),"B3查询网盘树节点下级列表(管理)-D3查询网盘树节点下级内容列表(公共)-上级目标内容类型编码不能为空",false);
Assert.isNull(queryNetDiskTreeSubordinateListComReqDto.getIsLastTargetContent(),"B3查询网盘树节点下级列表(管理)-D3查询网盘树节点下级内容列表(公共)-上级是否末级目标内容不能为空",false);
Assert.isNull(queryNetDiskTreeSubordinateListComReqDto.getEvaluationTemplateId(),"B3查询网盘树节点下级列表(管理)-D3查询网盘树节点下级内容列表(公共)-冗余评价模板ID不能为空",false);
      queryNetDiskTreeSubordinateListComRespDto = fwAppNetDiskTargetContentClient.queryNetDiskTreeSubordinateListCom(queryNetDiskTreeSubordinateListComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


      queryNetDiskTreeSubordinateListComRespDto_1 = queryNetDiskTreeSubordinateListComRespDto;

BffQueryNetDiskTreeSubordinateListRespDto retData = new BffQueryNetDiskTreeSubordinateListRespDto();
  if(queryNetDiskTreeSubordinateListComRespDto_1!=null){
      retData.setSubTargetContentList(queryNetDiskTreeSubordinateListComRespDto_1.getSubTargetContentList().stream().map(item -> BeanUtil.toBean(item, BffSubTargetContentDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1661469_1
    }




return retData;
  }
  //
}
